package com.tianyalei.wolf.sample.activity.bottomnavigation;

import android.app.Fragment;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationItem;
import com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationView;
import com.luseen.luseenbottomnavigation.BottomNavigation.OnBottomNavigationItemClickListener;
import com.tianyalei.wolf.mddesignlib.utils.FragmentUtil;
import com.tianyalei.wolf.sample.R;
import com.tianyalei.wolf.sample.activity.tablayout.BlankFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

public class BottomNavigationActivity extends AppCompatActivity {

    @Bind(R.id.bottomNavigation)
    BottomNavigationView bottomNavigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bottom_navigation);
        ButterKnife.bind(this);

        Fragment fragment = BlankFragment.newInstance("first", null);
        Fragment fragment1 = BlankFragment.newInstance("second", null);
        Fragment fragment2 = BlankFragment.newInstance("third", null);
        final FragmentUtil fragmentUtil = new FragmentUtil(this);
        fragmentUtil.setData(R.id.main_container, fragment, fragment1, fragment2);


        BottomNavigationItem bottomNavigationItem = new BottomNavigationItem
                ("Record", getResources().getColor(R.color.firstColor), R.drawable.ic_book_black_24dp);
        BottomNavigationItem bottomNavigationItem1 = new BottomNavigationItem
                ("Like", getResources().getColor(R.color.secondColor), R.drawable.ic_favorite_black_24dp);
        BottomNavigationItem bottomNavigationItem2 = new BottomNavigationItem
                ("Mic", getResources().getColor(R.color.thirdColor), R.drawable.ic_mic_black_24dp);

        bottomNavigationView.addTab(bottomNavigationItem);
        bottomNavigationView.addTab(bottomNavigationItem1);
        bottomNavigationView.addTab(bottomNavigationItem2);

        //不设置false的话，bottom带有背景色，点击后扩散到整个底部
        bottomNavigationView.isColoredBackground(false);

        //可以去掉BottomNavigationView的阴影
//        bottomNavigationView.disableShadow();
        bottomNavigationView.setOnBottomNavigationItemClickListener(new OnBottomNavigationItemClickListener() {
            @Override
            public void onNavigationItemClick(int index) {
                Toast.makeText(BottomNavigationActivity.this, "Item " + index + " clicked", Toast.LENGTH_SHORT).show();
                fragmentUtil.setCurrent(index);
            }
        });
    }
}
